Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape table name to allow for keywords conflict #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bbgw
Copy link

@bbgw bbgw commented Sep 24, 2021

Example

$ sas2db --db is.db --table is ~/Downloads/is.sas7bdat
Writing to is.db in sqlite using pysqlite...                                                                        
Writing to is table...                                                                                              
Traceback (most recent call last):                                                                                  
  File "/Users/***/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1772, in _execute_context
    cursor, statement, parameters, context                                                                          
  File "/Users/***/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute
    cursor.execute(statement, parameters)                                                                           
sqlite3.OperationalError: near "is": syntax error

With the fix

Writing to is.db in sqlite using pysqlite...
Writing to is table...
Wrote *** rows.

### Example
```bash
$ sas2db --db is.db --table is ~/Downloads/is.sas7bdat
Writing to is.db in sqlite using pysqlite...                                                                        
Writing to is table...                                                                                              
Traceback (most recent call last):                                                                                  
  File "/Users/***/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1772, in _execute_context
    cursor, statement, parameters, context                                                                          
  File "/Users/***/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute
    cursor.execute(statement, parameters)                                                                           
sqlite3.OperationalError: near "is": syntax error
```

### With the fix
```
Writing to is.db in sqlite using pysqlite...
Writing to is table...
Wrote *** rows.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant